﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Public;

namespace WebsiteAdmin.Wilson.Focus.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Delete : IHttpHandler
    {
        protected string responseText = "";
        protected string strCon = "";
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (Cookie.AdminLoginName != null || Cookie.AdminLoginName != "")  //判断登陆名是否存在
            {
                strCon = Global.ConnWilson;
                int PKID = Convert.ToInt32(context.Request["PKID"]);
                int result = DeleteFocusByPKID(PKID, strCon);
                if (result == 1)
                {
                    responseText = "{\"Done\": \"Success\"}";
                }
                else
                {
                    responseText = "{\"Done\":\"Failed\"}";
                }
                context.Response.Write(responseText);
            }
            else
            {
                context.Response.Clear();
                context.Response.CacheControl = "no-cache";
                context.Response.Write("");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// 根据PKID删除幻灯片——将Valid置为0
        /// </summary>
        /// <param name="pkid">PKID</param>
        /// <returns>1</returns>
        protected int DeleteFocusByPKID(int pkid, string strCon)
        {
            return new Bll.FocusSlide().DeleteFocusByPKID(pkid, strCon);
        }
    }
}
